//
// Created by hunan on 2025/10/6.
//
#include "../bw_statistic.h"
#include "../../loop_module/loop.h"
#include "../../timer/timer_task.h"
#include "../../log_module/log_public_module.h"
#include <gtest/gtest.h>

TEST(BwStatistic, Number)
{
    LOG_UPDATE_MODULE(TIMER_MODULE_NAME, 0);
    Loop loop;
    BWStatistic statistic(&loop);
    statistic.StartStatistic(5);
    TimerTask task(&loop);
    task.ExpireFromNow(6 * 1000, [&statistic]() {

        statistic += rand() % 360 + 1000;
    });
    TimerTask task1(&loop);
    task.ExpireFromNow(16 * 1000, [&statistic, &task]() {

        statistic.StopStatistic();
        task.Cancel();
    });
    loop.Run();
}